package com.config.controller;
import com.config.entity.TbSpecification;
import com.config.entity.TbSpecificationOption;
import com.config.service.TbSpecificationOptionService;
import com.config.util.PageResult;
import com.config.util.R;
import com.config.vo.TbSpecificationVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/student")
public class TbSpecificationOptionController {

    @Autowired
    private TbSpecificationOptionService tbSpecificationOptionService;

    @GetMapping("/list")
    public List<TbSpecificationOption> list(){
        return tbSpecificationOptionService.findAll();
    }
    @GetMapping("/findByPage")
    public PageResult<TbSpecificationOption> findByPage(@RequestParam("page") Integer page, @RequestParam("pageSize") Integer pageSize){
        return tbSpecificationOptionService
                .findByPage(page,pageSize);
    }
    @PostMapping("/search")
    public PageResult<TbSpecificationOption> search(@RequestParam("page") Integer page,
                                       @RequestParam("pageSize") Integer pageSize,
                                       @RequestBody(required = false) TbSpecificationVO studentVo){
        return tbSpecificationOptionService
                .search(page,pageSize,studentVo);
    }
    @PostMapping("/save")
    public R save(@RequestBody TbSpecificationOption student){
        return tbSpecificationOptionService.save(student) ? R.ok().message("添加成功！") : R.error().message("添加失败！");
    }
}